{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install pandas\n",
    "!pip install flask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from flask import Flask  #1. 导入flask\n",
    "from flask import request\n",
    "from flask import render_template\n",
    "app = Flask(__name__)  #2. 创建flask应用实例\n",
    "\n",
    "\n",
    "@app.route('/')  #3.定义路由和视图函数。 \n",
    "def index():\n",
    "   #p = request.arg.get('p')\n",
    "    return 'Index Page' #render_template('xxx.html',name = p)\n",
    "\n",
    "if __name__ == '__main__':  \n",
    "    app.run()   #4. 启动主函数，\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from flask import Flask  #1. 导入flask\n",
    "from flask import request\n",
    "from flask import render_template\n",
    "import pandas as pd\n",
    "app = Flask(__name__)  #2. 创建flask应用实例\n",
    "\n",
    "@app.route('/flask/<name>')  #3.定义路由和视图函数。 \n",
    "def test(name):\n",
    "    print(name)\n",
    "    df = pd.read_csv(r\"C:\\Users\\PC\\Desktop\\gdp.csv\").set_index('province')\n",
    "    if name in df.index:\n",
    "        city_gdp = df.loc[name]\n",
    "        gdp_years = list(zip(city_gdp.index,city_gdp.values))\n",
    "        print(gdp_years)\n",
    "    else:\n",
    "        gdp_years = []\n",
    "        \n",
    "    return render_template('yyy.html',city = name,gdp_years = gdp_years)\n",
    "\n",
    "if __name__ == '__main__':  \n",
    "    app.run()   #4. 启动主函数，\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
